home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / BBMAINT3.CMD < prev    next >
OS/2 REXX Batch file  |  1992-03-24  |  24KB  |  914 lines

  1. ;****    TRACE ON        ; Debugging
  2. ;
  3. ; ----- COM-AND BBS file maintenance script (BULLETIN file)
  4. ;    Commenced: 11/90 R.McG
  5. ; -----------------------------------------------------------------------
  6. ;    Purpose:
  7. ;       The script, named BBMAINT3.CMD, produces the main window for
  8. ;    Bulletin functions of BBMAINT, and implements its functions.  It
  9. ;    is not directly callable itself.
  10. ; -----------------------------------------------------------------------
  11. ;    Usage:
  12. ;       N99 -> Text attribute value (Setup by BBMAINT.CMD)
  13. ;       N98 -> BBMAINT Mainline cursor position
  14. ;       N97 -> BBMAINT Mainline cursor position
  15. ;       N96 -> our mainline cursor position
  16. ;       N95 -> our mainline cursor position
  17. ; -----------------------------------------------------------------------
  18. ;
  19. ;    This script is intended ONLY to be used for FCALL
  20. ;
  21.     IF NOT FCALLED
  22.        WOPEN 10,10,13,70 (cont) NOBUEsc
  23.        ATSAY 10,12 (cont) " BBS Bulletin "
  24.        ATSAY 11,12 (cont) " The script: "*"_SCRIPT"
  25.        ATSAY 12,12 (cont) " is not used by itself... it is called through BBMAINT"
  26.        ATSAY 13,26 (cont) " Press any key to continue "
  27.        ;
  28.        ;    Wait a keypress
  29.        ;
  30.        KEYGET S0        ; Wait for any key
  31.        WCLOSE        ; Close open window
  32.        EXIT         ; Terminate right here
  33.        ENDIF
  34.     GOSUB Bullfile        ; Invoke function
  35.     FRETURN         ; Return to caller
  36. ; -----------------------------------------------------------------------
  37. ; ----- NoBull:  Inform that there's no BBS-Bull file to modify
  38. ;
  39. NoBull:
  40.     WOPEN 10,10,13,70 (cont) NOBUEsc
  41.     ATSAY 10,12 (cont) " BBS BullDir "
  42.     ATSAY 11,12 (cont) " The file: "*S25&"\BBS-Bull"
  43.     ATSAY 12,12 (cont) " does not exist.  Please create subdirectories first."
  44.     ATSAY 13,26 (cont) " Press any key to continue "
  45.     ;
  46.     ;    Wait a keypress
  47.     ;
  48.     KEYGET S0        ; Wait for any key
  49.     WCLOSE
  50. NOBUEsc:
  51.     RETURN
  52. ; -----------------------------------------------------------------------
  53. ; ----- Subroutine: BullFile -> Update Bulletin directory
  54. ;
  55. BullFile:
  56.     GOSUB NewBull        ; Create if not there
  57.     IF NOT ISFILE S25&"\BBS-Bull"
  58.        GOSUB NoBull     ; Inform there's no file
  59.        RETURN        ; .. so we can't continue
  60.        ENDIF
  61. ;
  62. ;    Open a window
  63. ;
  64.     WOPEN 0,0 23,79 (defa) Bull_Esc
  65.     ATSAY 0,2 (defa)   " BBS Bulletins "
  66.     ATSAY 23,25 (defa) " Press ESC to cancel BBMAINT "
  67. ;
  68. ;    Paint the window
  69. ;
  70. BUFI100:
  71.     CLEAR            ; Clear window
  72.     LOCATE 2,2
  73.  
  74.     MESS " 1) Add a bulletin to the list"
  75.     MESS " 2) Delete a bulletin from the list"
  76.     MESS " 3) Modify a bulletin's listing"
  77.     MESS " 4) Print the bulletin list"
  78.     MESS " 5) View the bulletin list"
  79.     MESS "──────────────────────────────────── "
  80.     MESS "Note: Alt-Q to edit a file"
  81.     MESS "      Alt-F for a directory search"
  82.     MESS "      Alt-F10 to shell to DOS"
  83.     MESS " "
  84.     MESS "──────────────────────────────────── "
  85.     MESS " "
  86.     MESS "Select item (carriage return = previous): "
  87.     CURSOR N96,N95        ; Read current cursor
  88. ;
  89. ;    Wait for entry, and interpret
  90. ;
  91. BUFI200:
  92.     LOCATE N96 N95        ; Reposition cursor
  93.     KEYGET S0        ; Wait for it
  94.     SWITCH S0        ; Act according to keyget
  95.       CASE "1"
  96.            GOSUB AddBull
  97.            ENDCASE
  98.       CASE "2"
  99.            GOSUB DelBull
  100.            ENDCASE
  101.       CASE "3"
  102.            GOSUB ModBull
  103.            ENDCASE
  104.       CASE "4"
  105.            GOSUB PrnBull
  106.            ENDCASE
  107.       CASE "5"
  108.            GOSUB ViewBull
  109.            GOTO BUFI100    ; Repaint screen after this
  110.            ENDCASE
  111.       CASE "0d"             ; c/r alone is exit
  112.            WCLOSE        ; Close window...
  113.            RETURN        ; and return to caller
  114.            ENDCASE
  115.       CASE "_NULL"          ; ESC -> Null
  116.            WCLOSE        ; Close window...
  117.            RETURN        ; Leave Main routine
  118.            ENDCASE
  119.       CASE "2100"           ; Alt-F
  120.            MANUAL "0x2100"  ; Perform Dir cmd
  121.            ENDCASE
  122.       CASE "1000"           ; Alt-Q
  123.            MANUAL "0x1000"  ; Edit a file
  124.            ENDCASE
  125.       CASE "7100"           ; Alt-F10
  126.            SHELL
  127.            DWINDOW 1,2,22,78; Reset dwindow after shell
  128.            LEGEND "_LEGEND" ; Redo the legend
  129.            ENDCASE
  130.       DEFAULT        ; None of the above
  131.            SOUND 100,100    ; Bronx cheer
  132.            ENDCASE
  133.       ENDSWITCH
  134.     GOTO BUFI200        ; Repaint screen and ask again
  135. ;
  136. ;    End of bulletin procedure
  137. ;
  138. Bull_Esc:
  139.     S0 = ""                 ; Fake a null entry
  140.     RETURN            ; Leave bulletin routine
  141. ; -----------------------------------------------------------------------
  142. ; ----- AddBUll:  Add a file to the bulletin directory
  143. ;
  144. AddBull:
  145.     SET FLAG(0) OFF     ; Flag for ESCAPE
  146.     WOPEN 10,10,17,75 (cont) ADBUEsc
  147.     ATSAY 10,12 (cont) " BBS Bulletin Add "
  148.     ATSAY 11,12 (cont) "Enter the bulletin number: "
  149.     ATSAY 17,26 (cont) " Press ESC to cancel "
  150.     ;
  151.     ;    Wait a keypress
  152.     ;
  153.     LOCATE 11,42
  154.     GET S0 5        ; get number
  155.     IF FLAG(0) GOTO ADBUEnd ; Exit if ESC hit
  156.     LJ S0            ; Left justify
  157.     UPPER S0        ; Upper casefy
  158.     IF NULL S0 GOTO ADBUEnd ; get out on empty entry
  159.     GOSUB LkpBull        ; Lookup name in file
  160.     IF FOUND        ; If its there we can't add it
  161.        WCLOSE        ; Close open window
  162.        GOTO ModBU_Add    ; Skip if found
  163.        ENDIF
  164.     S10 = S0        ; Save File name
  165.     GOTO ADBU100        ; And branch around parallel code
  166. ;
  167. ;    Entry from ModBull... Nothing to modify
  168. ;
  169. AddBU_Mod:
  170.     WOPEN 10,10,17,75 (cont) ADBUEsc
  171.     ATSAY 10,12 (cont) " BBS Bulletin Add "
  172.     ATSAY 11,12 (cont) "Enter the bulletin number: "
  173.     ATSAY 11,42 (cont) S0
  174.     ATSAY 17,26 (cont) " Press ESC to cancel "
  175.     S10 = S0        ; Copy it for remainder
  176. ;
  177. ;    Place file date and time in record
  178. ;
  179. ADBU100:
  180.     DATE S1         ; Want mm/dd/yy form
  181.     S10(5:12) = S1        ; Save date added
  182.     ATSAY 12,12 (cont) "Enter the file name:"
  183.     LOCATE 12,42
  184.     GET S0 12        ; get file name
  185.     IF FLAG(0) GOTO ADBUEnd ; Exit if ESC hit
  186.     LJ S0            ; Left justify
  187.     IF NULL S0
  188.        SOUND 100,100    ; Indicate displeasure
  189.        GOTO ADBU100     ; Try again
  190.        ENDIF
  191.     FFIRST S25&"\"*S0       ; Test for file's existence
  192.     S10(14:25) = S0     ; Save File name
  193.     IF SUCCESS GOTO ADBU200 ; Skip if exists
  194. ;
  195. ;    File does not exist...
  196. ;
  197. ADBU110:
  198.     ATSAY 13,12 (cont) "File d.n.e. Add anyway (y/n): "
  199.     LOCATE 13,42
  200.     GET S0 1        ; get resp
  201.     IF FLAG(0) GOTO ADBUEnd ; Exit if ESC hit
  202.     IF NULL S0 or NOT FIND "YN" S0(0)
  203.        SOUND 100,100    ; Indicate displeasure
  204.        GOTO ADBU110     ; Try again
  205.        ENDIF
  206.     IF FIND "N" S0(0)
  207.        WCLOSE        ; Close window
  208.        GOTO AddBull     ; And try again
  209.        ENDIF
  210. ;
  211. ;    Ask for a comment field
  212. ;
  213. ADBU200:
  214.     ATSAY 14,12 (cont) "Description: "
  215.     LOCATE 14,26
  216.     GET S0 40        ; get resp
  217.     LJ S0            ; Left justify
  218.     IF FLAG(0) GOTO ADBUEnd ; Exit if ESC hit
  219.     IF NULL S0
  220.        SOUND 100,100    ; Indicate displeasure
  221.        GOTO ADBU200     ; Try again
  222.        ENDIF
  223.     S10(26:79) = S0     ; Save comment text
  224. ;
  225. ;    Ask for privileged flag
  226. ;
  227. ADBU250:
  228.     ATSAY 15,12 (cont) "Priveleged access (y/n):  "
  229.     LOCATE 15,42
  230.     GET S0 1        ; get resp
  231.     IF FLAG(0) GOTO ADBUEnd ; Exit if ESC hit
  232.     IF NULL S0 or NOT FIND "YN" S0(0)
  233.        SOUND 100,100    ; Indicate displeasure
  234.        GOTO ADBU250     ; Try again
  235.        ENDIF
  236.     IF FIND "Y" S0(0) S10(13:13) = "P" ; Save priveleged access
  237. ;
  238. ;    Ask for one more look
  239. ;
  240. ADBU300:
  241.     ATSAY 16,12 (cont) "OK to add this record?:   "
  242.     LOCATE 16,42
  243.     GET S0 1        ; get resp
  244.     IF FLAG(0) GOTO ADBUEnd ; Exit if ESC hit
  245.     IF NULL S0 or NOT FIND "YN" S0(0)
  246.        SOUND 100,100    ; Indicate displeasure
  247.        GOTO ADBU300     ; Try again
  248.        ENDIF
  249.     IF FIND "N" S0(0)
  250.        WCLOSE        ; Close window
  251.        GOTO AddBull     ; And try again
  252.        ENDIF
  253. ;
  254. ;    Write the record
  255. ;
  256.     GOSUB AddBRec        ; Write to Bulletins file
  257. ;
  258. ;    End of add procedure
  259. ;
  260. ADBUEnd:
  261.     WCLOSE
  262. ADBUEsc:
  263.     SET FLAG(0) ON
  264.     RETURN
  265. ; -----------------------------------------------------------------------
  266. ; ----- AddBRec:  Add a record to the Bulletin file...
  267. ;    .. S10 passes the record to be written
  268. ;
  269. AddBRec:
  270.     FOPENO S25&"\BBS-bull" TEXT APPEND
  271.     IF NOT SUCCESS        ; Open failed
  272.        S0 = "Error opening: "*S25&"\BBS-Bull"
  273.        GOSUB Error        ; Report
  274.        RETURN        ; And we're done
  275.        ENDIF
  276.     PRESERVE S10        ; Preserve ^'s and !'s
  277.     WRITE S10        ; Write the record
  278.     WRITE "!^Z"             ; And finish it
  279.     FCLOSEO
  280.     RETURN
  281. ; -----------------------------------------------------------------------
  282. ; ----- LkpFile:  Lookup a file in the BBS-Bull file
  283. ;    .. S0 passes the fname to be tested
  284. ;    .. S10 returns the record read
  285. ;
  286. LkpBul